package org.giovanolli.mumi.controller.geo;

import org.giovanolli.mumi.controller.AbstractController;
import org.giovanolli.mumi.controller.AbstractModel;
import org.giovanolli.mumi.entities.Region;
import org.giovanolli.mumi.entities.filter.RegionFilter;
import org.giovanolli.mumi.service.RegionService;
import org.giovanolli.mumi.service.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller("regionController")
public class RegionController extends AbstractController<Region> {

	@Autowired
	private RegionService service;

	@Autowired
	private RegionModel model;

	@Override
	protected void bindEntityToModel() {
		Region editedRegion = model.getEditedEntity();
		model.setName(editedRegion.getName());
	}

	@Override
	protected void bindModelToEntity() {
		Region editedRegion = model.getEditedEntity();
		editedRegion.setName(model.getName());
	}

	protected Class<Region> getEntityClass() {
		return Region.class;
	}

	@Override
	protected AbstractModel<Region> getModel() {
		return model;

	}

	@Override
	protected Service<Region> getService() {
		return service;
	}

	public void init() {
		super.init();
		model.setFilter(new RegionFilter());
	}
}
